package org.southyin.controller;

import org.southyin.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;
import java.util.Arrays;

@Controller
@RequestMapping("/user")
public class HelloController {
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public void hello() {
        System.out.println("hello springmvc1");
    }

    @RequestMapping(value = "/hello2", method = RequestMethod.GET)
    public void hello2() {
        System.out.println("hello springmvc2");
    }

//    @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
//    public void  userDoLogin1(String email,String password){
//        System.out.println(email);
//        System.out.println(password);
//    }

    @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
    public void  userDoLogin1(@RequestParam(value = "email") String e,@RequestParam(value = "password") String p){
        System.out.println(e);
        System.out.println(p);
    }


    @RequestMapping(value = "/doLogin2", method = RequestMethod.POST)
    public void  userDoLogin2(User user){
        System.out.println(user.getEmail());
        System.out.println(user.getPassword());
    }

    @RequestMapping(value = "/doLogin3", method = RequestMethod.POST)
    public void userDoLogin3(int id) {
        System.out.println(id);
    }

    @RequestMapping(value = "/doLogin4", method = RequestMethod.POST)
    public void  userDoLogin4(int[] ids){
        System.out.println(Arrays.toString(ids));
    }

    @RequestMapping(value = "/doLogin5", method = RequestMethod.POST)
    public void  userDoLogin5(@RequestBody User user){
        System.out.println(user.getEmail());
        System.out.println(user.getPassword());
    }

    @RequestMapping(value = "/doLogin6", method = RequestMethod.POST)
    public void  userDoLogin6(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        System.out.println(pageNum);
        System.out.println(pageSize);
    }
}
